<!-- 教练 – 首页 – 约课详情			All -->
<template>
	<view class="">
		<view @click="gotime" class="pl15 pr15" style="height: 100rpx;line-height: 100rpx;position: sticky; top: 0; left: 0;background-color: #F8F8F9;">
			<u-section title="选择日期：" :sub-title="time"></u-section>
		</view>
		
		<!-- 这是内容 -->
		<view class="bg-fff" v-if="data != ''">
			<view class=" pt10 pb10 bb" v-for="(item,index) in data" :key="index" @click="ao(item)">
				<view class="w93 f b">
					<view>
						<image style="width: 240rpx;height: 156rpx;" :src="item.course_img" mode=""></image>
					</view>
					<view class=" f d" style="width: 63%;">
						<text class="fs28 bold ellipsis">{{item.course_name}}</text>
						<text class="fs20 hui p_t_10 ellipsis">{{item.course_title}}</text>
						<view class="f b p_t_40">
							<view class="">
								<text>{{item.timestr}}</text>
							</view>
							<view class="information-buts">
								<view class="f b c pl5 pr5">
									<text >会员{{item.vip_num}}人</text>
									<view class="" style="margin-top:-10rpx;">|</view>
									<text >体验{{item.ty_num}}人</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="dis-flex flex-align-center flex-center" style="height: 1000rpx;" v-else>
			<u-empty text="列表为空" mode="list"></u-empty>
		</view>
		
		<u-calendar v-model="show" mode="date" @change="change" :change-year="false"  :max-date="max_time"></u-calendar>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				time: '', 
				min_time:'',
				max_time:'',
				show: false,
				data: []
			}
		},
		onLoad() {
			// 动态导航条文字
			uni.setNavigationBarTitle({
				title: '全部课程'
			})
			var date = new Date();
			var yue = date .getMonth()+1
			if(yue < 10){
				var yue ='0'+yue
			} 
			var day = date .getDate()
			if(day < 10){
				var day ='0'+day
			} 
			this.min_time = this.time = date.getFullYear() + "-" + yue + "-" + day
			var date2 = new Date(date);
			date2.setDate(date.getDate() + 6);
			//num是正数表示之后的时间，num负数表示之前的时间，0表示今天
			this.max_time = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
			this.init()
		},
		methods: {
			init(){
				var that = this
				var json = {
					date: that.time,
				}
				that.$http.post(that.$config.UrlPostyukeList, json).then((res) => {
					if (res.status == 1) {
						that.data = res.data
					}
				})
			},
			gotime() {
				this.show = !this.show 
			},
			change(e){
				this.time = e.result
				this.init()
			},
			ao(item){
				var data = encodeURIComponent(JSON.stringify(item))
				uni.navigateTo({
					url:"../details/details?data="+data
				})
			}
		}
	}
</script>

<style scoped>
	

	.information-buts {
		width: 228rpx;
		height: 36rpx;
		line-height: 36rpx;
		font-size: 20rpx;
		opacity: 1;
		background: #ffffff;
		border: 2rpx solid #1f73f2;
		border-radius: 18rpx 18rpx 18rpx 18rpx;
		color: #1f73f2;
	}

	.All-lan {
		width: 120rpx;
		height: 94rpx;
		opacity: 1;
		background: #1f73f2;
	}
</style>
